package cn.dankal.flyaudio.friend;

import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.StringUtils;

import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.pojo.MessageEntity;
import cn.dankal.basiclib.util.WebViewUtil;
import cn.dankal.basiclib.widget.DKWebView;
import cn.dankal.business.pojo.NotificationBean;
import cn.dankal.flyaudio.R;

public class MessageDetailActivity extends BaseActivity {
    private NotificationBean messageEntity;

    private TextView messageTypeView;
    private DKWebView dkWebview;
    private TextView messageContentView;

    private String messageType;
    @Override
    protected int getLayoutId() {
        return R.layout.activity_message_detail;
    }

    @Override
    protected void initComponents() {
        messageEntity = (NotificationBean) getIntent().getSerializableExtra("message");
        messageType = getIntent().getStringExtra("messageType");
        messageTypeView = findViewById(R.id.tv_message_type);
        messageContentView = findViewById(R.id.tv_message_content);
        dkWebview = findViewById(R.id.dk_webview);
        if (messageEntity == null) {
            finishActivity();
        }
        findViewById(R.id.iv_onback).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        messageContentView.setText(messageEntity.getCreateTime());

        if (StringUtils.equals("0", messageType)) {
            messageTypeView.setText("系统消息");
            WebViewUtil.loadData(dkWebview, messageEntity.getContent());
        } else if (StringUtils.equals("1", messageType)) {
            messageTypeView.setText("预约消息");
            WebViewUtil.loadData(dkWebview,
                    "恭喜你，你已经成功预约活动"+messageEntity.getTitle()+"\n活动详情为：" +messageEntity.getContent());
        } else if (StringUtils.equals("2", messageType)) {
            messageTypeView.setText("评论消息");
            WebViewUtil.loadData(dkWebview,
                    messageEntity.getSendName()+"已评论你的"+messageEntity.getContent());
        } else if (StringUtils.equals("3", messageType)) {
            messageTypeView.setText("积分领取消息");
            WebViewUtil.loadData(dkWebview, messageEntity.getContent());
        } else if (StringUtils.equals("4", messageType)) {
            messageTypeView.setText("关注消息");
            WebViewUtil.loadData(dkWebview, messageEntity.getContent());
        }
    }
}
